package com.hellokoding.springboot.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class HelloController {
    Logger logger = LoggerFactory.getLogger(HelloController.class);

    //调用可以用http://localhost:8080/hello?name=yaox
    @GetMapping({"/", "/hello"})
    public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) {
        logger.info("进入了index");
        logger.error("这是测试的");
        model.addAttribute("name", name);
        return "hello";
    }
}